<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<%@page import="org.apache.commons.lang.StringUtils"%>
<%@ page language="java" import="java.util.*" pageEncoding="utf-8"%>
<html xmlns="http://www.w3.org/1999/xhtml">
<%
	String version = (String)request.getAttribute("version");
	JSONArray menuList = (JSONArray)request.getAttribute("menuList");
	String htmlStr = "";
	for(int i =0;i<menuList.size();i++){
		JSONObject jsonObject= menuList.getJSONObject(i);
		if(jsonObject.get("selected")!=null&&(Boolean)jsonObject.get("selected")==true){
			if(StringUtils.isNotBlank(jsonObject.getString("url"))){
				htmlStr = htmlStr +"<li class='header-nav-item ' name='menuGroup' href1='"+contextPath+jsonObject.get("url")+"'><a class='header-nav-item-txt'>"+jsonObject.get("text")+"</a>";
			}else{
				htmlStr = htmlStr +"<li class='header-nav-item' name='menuGroup'><a class='header-nav-item-txt'>"+jsonObject.get("text")+"</a>";
			}
		htmlStr = htmlStr + getChildMenu(jsonObject,contextPath)+"</li>";
		}
	}
%>
<%!
	public String getChildMenu(JSONObject obj,String contextPath){
		JSONArray jsonArray = obj.getJSONArray("children");
		String htmlStr = "";
		if(jsonArray!=null && jsonArray.size()>0){
			htmlStr += "<div  class='nav-list'> <div class='nav-list-wrap'>";
			for(int i=0;i<jsonArray.size();i++){
				JSONObject jsonObject = jsonArray.getJSONObject(i);
				if(jsonObject.get("checked")!=null&&(Boolean)jsonObject.get("checked")==true){
				    if(jsonObject.getString("menuType")==null || "".equals(jsonObject.getString("menuType"))){
						String  menuHref = contextPath+jsonObject.getString("url");
						htmlStr = htmlStr +"<p class='nav-list-item ' name='menuItem' href1='"+menuHref+"'><i class='icon "+jsonObject.getString("iconClass")+"'></i><a title='"+jsonObject.getString("text")+"'>"+jsonObject.getString("text")+"</a></p>";
					}else{
						htmlStr = htmlStr +"<p class='nav-line'></p>";
					}
				}
			}
			htmlStr += "</div></div>";
		}else{
			return "";
		}
		return htmlStr;
	}
	
%>
<head>
<title><%=CommonConfig.getString("SYSTEM_TITLE")%></title>
<meta http-equiv="X-UA-Compatible" content="edge" />
</head>
<body>
<div class="header">
	<div class="header-left">
		<img src="<%=contextPath%>/images/console/logo.png">
		<div class="version">V<%=version %></div>
	</div>
	<div class="header-content">
		<ul class="header-nav">
			<%out.print(htmlStr); %>
		</ul>
	</div>
	<div class="header-right">
		<ul class="header-nav">
		<li class="header-nav-item nav-list-li">
			<span><i class="icon ico-icoyj ml5 font_28"></i></span>
			<p class="nav-mask">13+</p>
		</li>

		<li class="header-nav-item nav-list-li">
			<a href="javascript:;" class="header-nav-item-txt nav-list-user">
				<img src="<%=contextPath%>/images/console/user.png">
				<span class="user-name-item"><%=userInfo.getString("name") %></span>
			</a>
			<%--<a href="javascript:;" class="header-nav-item-txt nav-list-user"><%=userInfo.getString("name") %></a>--%>
			<div  class="nav-list user-list">
				<div class="nav-list-wrap">
					<%
						if("0".equals(userInfo.getString("usertype"))){
					%>
					<p class="nav-list-item"> <i class="icon ico-icoglyh"></i> <a href="javascript:void(0);" onclick="javascript:loadMenu('<%=contextPath%>/console/user/list')"  class="nav-list-a">管理人员</a> </p>
					<%
						}
					%>
					<p class="nav-list-item"> <i class="icon ico-icojkwd"></i> <a href="javascript:void(0);" onclick="javascript:loadMenu('<%=contextPath%>/console/userLog/list')"  class="nav-list-a">运维日志</a> </p>
					<p class="nav-line"></p>
					<p class="nav-list-item"> <i class="icon ico-ryaochi"></i> <a href="javascript:void(0);" onclick="javascript:updatePassword('<%=contextPath%>/console/user/goUpdatePwd?loginId=<%=userInfo.getString("loginId") %>')"  class="nav-list-a">修改密码</a> </p>
					<p class="nav-list-item"> <i class="icon ico-icoregret"></i> <a href="javascript:window.parent.location='<%=contextPath%>/logout';"  class="nav-list-a">退出</a> </p>
				</div>
			</div>
		</li>
		</ul>
	</div>
</div>
<script type="text/javascript">


$(function(){
    $('.nav-list-item').click(function(){
        $(".header").find(".header-nav-item").removeClass("active");
        $('.nav-list-item').removeClass('active');
        $(this).addClass('active');
    })
    $('.header-nav-item').click(function(){
        $(".header").find(".header-nav-item").removeClass("active");
        $(this).addClass('active').siblings('.header-nav-item').removeClass('active');
    })

	$("p[name='menuItem']").click(function(){
		var url = $(this).attr("href1");
		if(url!=undefined && url!=""){
			loadMenu(url);
			$(".cur").removeClass("cur");
			$(this).addClass("cur");
			$(this).parent().parent("li[name='menuGroup']").addClass("cur");
		}
	});
	$("li[name='menuGroup']").click(function(){
		var url = $(this).attr("href1");
		if(url!=undefined && url!=""){
		loadMenu(url);
			$(".cur").removeClass("cur");
			$(this).addClass("cur");
		}
	});

	$("#logSpan").mouseover(function(){
		var versionInfo = $(this).attr("version")
		index = apexLayer.Tips({
			message:versionInfo,
			more:false,
			object:this,
			guide:3,
			time:0
		});
	});
	$("#logSpan").mouseout(function(){
		apexLayer.CloseAll();
	});

	});
	function loadMenu(url){
		if(url!=undefined){
			$("#content").attr("src",url);
		}
	}

	function updatePassword(url){
		$("#content").attr("src",url);
	}
</script>
</body>
</html>